"""
@author: chy
@file: 读取文件前五行.py
@time: 2023/12/9 15:17
"""
import os

file_path = '/etc/ssh/sshd_config'

# 检查文件是否存在
if os.path.exists(file_path):
    # 打开文件并读取前5行
    with open(file_path, 'r') as file:
        for i in range(5):
            line = file.readline()
            # 过滤以#号开头的行和空行
            if not line.startswith('#') and line.strip():
                print(line.strip())
else:
    print(f"The file {file_path} does not exist.")